/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.compomics.dataprovider.playground;

import com.compomics.dataprovider.control.logic.fasta.FastaSourceConverter;
import com.compomics.dataprovider.model.fasta.FastaStream;
import java.io.File;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Kenneth
 */
public class RedundancyClearage {

    public static void main(String[] args) {
        File inputFolder = new File("C:\\Users\\Kenneth\\Desktop\\N-term project\\Fasta");
        for (File aFile : inputFolder.listFiles()) {
            if (aFile.getName().toLowerCase().endsWith(".fasta")) {
                try {
                    File outputFile = new File(aFile.getAbsolutePath().replace(".fasta", ".nr.fasta"));
                    outputFile.createNewFile();
                    FastaStream out = new FastaStream(FastaSourceConverter.convertToStream(outputFile));
                    out.concatenate(aFile).removeDuplicateSequences();
                    out.save(outputFile, true);
                } catch (IOException | NullPointerException ex) {
                    Logger.getLogger(RedundancyClearage.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
        }
    }
}
